#include "widget.h"
#include "ui_widget.h"

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);
}

Widget::~Widget()
{
    delete ui;
}

void Widget::on_pushButton_clicked()
{
    QDateTime oldtime=ui->dateTimeEdit_old->dateTime();
    QDateTime newtime=ui->dateTimeEdit_new->dateTime();

    //内置时间计算方法
    int days=oldtime.daysTo(newtime);
    int hours=(oldtime.secsTo(newtime)/3600)%24;

    QString text = QString("你欠我钱已经持续了 ") + QString::number(days) +
                   QString(" 天 零 ")+ QString::number(hours) + QString(" 个⼩时!");
    ui->label->setText(text);


}

